<?php
class Wenda_Table_Answer extends Life_Model_Table_Abstract
{
    protected $_name        = 'answer';

    public function findById($id)
    {
        return $this->find((int)$id)->current();
    }

    public function getAnswers($queryId , $page=null)
    {
        $queryId = (int)$queryId;

        $select = $this->_db->select();
        $select->from('answer as a')
               ->joinLeft('user as u','a.user_id = u.id','u.name as user_name')
               ->where('query_id = ?',$queryId)
               ->order('created_at');
        
        return $this->_db->fetchAll($select);
    }
}
